﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OracleClient;


public partial class TrangTheLoai : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataConnection.str = @"Data Source=xe;User ID=ODER;Password=12345";
        int loaiKT = int.Parse(Request.QueryString["loai"]);        
        DataTable bang = new DataTable();        
        OracleParameter[] thamso = new OracleParameter[]
        {
                new OracleParameter("p_maloaisach",loaiKT),   
        };

        bang = DataConnection.GetDatatableByStoreProcedureNameCursor("NGOCTRAN.sp_getSachByMaLoaiSach", thamso);

        dlsanpham.DataSource = bang;
        dlsanpham.DataBind();
        clp1.PageSize = 8;
        clp1.DataSource = getSP().Tables[0].DefaultView;
        clp1.BindToControl = dlsanpham;
        dlsanpham.DataSource = clp1.DataSourcePaged;
        dlsanpham.DataBind();



        OracleParameter[] thamso1 = new OracleParameter[]
        {
                new OracleParameter("p_maloaisach",loaiKT),   
        };

        DataTable bang1 = DataConnection.GetDatatableByStoreProcedureNameCursor("NGOCTRAN.sp_getTenLoaiSachByMaLoaiSach", thamso1);

        lbtheloai.Text = bang1.Rows[0][0].ToString();
    }


    public DataSet getSP()
    {
        string masach = Convert.ToString(Request.QueryString["loai"]);
        OracleConnection con = DataConnection.TaoKetNoi();
        OracleCommand cmd;
        OracleDataAdapter da;
        try
        {
            
            cmd = new OracleCommand("NGOCTRAN.sp_getSachByMaLoaiSach", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("p_maloaisach", OracleType.Number).Value = masach;
            cmd.Parameters.Add("p_recordset", OracleType.Cursor).Direction = ParameterDirection.Output;
            DataSet ds = new DataSet();
            da = new OracleDataAdapter(cmd);
            da.Fill(ds);
            return ds;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }



    protected void dlsanpham_SelectedIndexChanged(object sender, EventArgs e)
    {
    }
}